package com.cmower.baeldung.string2;

import java.nio.charset.Charset;
import java.util.Random;

/**
 * @author 沉默王二，一枚有趣的程序员
 */
public class RandomStringTest {
    public static void main(String[] args) {
int leftLimit = 97; // 'a'
int rightLimit = 122; // 'z'
int targetStringLength = 6;
Random random = new Random();
StringBuilder buffer = new StringBuilder(targetStringLength);
for (int i = 0; i < targetStringLength; i++) {
    int randomLimitedInt = leftLimit + (int)
            (random.nextFloat() * (rightLimit - leftLimit + 1));
    buffer.append((char) randomLimitedInt);
}
String generatedString = buffer.toString();

System.out.println(generatedString);



    }
}
